<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>事件绑定</title>
    <script src="./js/vue.js"></script>
</head>

<body>
    <div id="app">
        {{msg}}
        <h2>年龄:{{age}}</h2>
        <button v-on:click="addAge">点击一下年龄+1</button>
        <button @click="subtractAge">点击一下年龄-1</button>
    </div>
</body>

</html>
<script>
    new Vue({
        el: "#app",
        data: {
            msg: "hello",
            age: 18,
        }, methods: { //methods:用来定义vue中方法
            //点击年龄+1
            addAge: function () {
                this.age++;
            },
            //点击年龄-1
            subtractAge: function () {
                this.age--;
            }
        },
    });
</script>